﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

namespace LabMS.Web
{
    public partial class Home : Base.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            InitData();
        }

        private void InitData()
        {
            ExtendBLL.Announcement notice = new ExtendBLL.Announcement();
            ExtendBLL.Resource resource = new ExtendBLL.Resource();
            ExtendBLL.Post post = new ExtendBLL.Post();

            List<LabMS.Model.Announcement> latestNotices;
            List<LabMS.Model.Resource> latestResources;
            List<LabMS.Model.Post> latestPosts;

            latestNotices = notice.GetLatest(10);
            latestResources = resource.GetLatest(10);
            latestPosts = post.GetLatest(10);

            RepeaterNotices.DataSource = latestNotices;
            RepeaterNotices.DataBind();

            RepeaterResources.DataSource = latestResources;
            RepeaterResources.DataBind();

            RepeaterPosts.DataSource = latestPosts;
            RepeaterPosts.DataBind();
        }

        public string GetStuctureName()
        {
            switch (UserType)
            {
                case "mana":
                    return "Structure";
                case "teacher":
                    return "TeacherStructure";
                case "student":
                    return "StudentStructure";
                default:
                    return String.Empty;
            }
        }
    }
}
